import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

import cuke4duke.annotation.I18n.EN.Given;
import cuke4duke.annotation.I18n.EN.Then;
import cuke4duke.annotation.I18n.EN.When;
import org.openqa.selenium.ie.InternetExplorerDriver;

import static junit.framework.Assert.assertNotNull;

/**
 * Created by IntelliJ IDEA.
 * User: VMoskalenko
 * Date: 07.02.12
 * Time: 14:11
 */
public class LondonSteps {

    private WebDriver driver;
    private WebElement locationElement;

    public LondonSteps() {
        this.driver = new InternetExplorerDriver();
    }

    @Given("^I have accessed Hotwire's international home page$")
    public void accessHotwireInternationalHomePageStep() {
        driver.get("http://www.hotwire.com/uk");
    }

    @When("^I enter \"(.*)\" in FF$")
    public void enterLocationInFareFinderStep(String location) {
        locationElement = driver.findElement(By.name("location"));
        locationElement.clear();
        locationElement.sendKeys(location);
        driver.findElement(By.name("startDate")).clear();
        driver.findElement(By.name("startDate")).sendKeys("12/02/12");
        driver.findElement(By.name("endDate")).clear();
        driver.findElement(By.name("endDate")).sendKeys("14/02/12");
    }

    @When("^click the \"Search for your hotel\" button$")
    public void submitFareFinderStep() {
        locationElement.submit();
    }

    @Then("opaque result list is displayed")
    public void displayOpaqueResultListStep() throws InterruptedException {
        Thread.sleep(15000L);
        System.out.println(driver.getPageSource());
        assertNotNull(driver.findElement(By.id("opaqueResultsList")));
    }
}
